import commonConstant from "../common/commonConstant.js";
import {animationInfo} from "./animation.js";

export const elementType = {
    area: "area",
    chess: "chess",
    shadow: "shadow",
    canBuildChess: "canBuildChess",
}
// export let row = 19
// export let col = 11
// export let chessWidth = 0
// export let chessHeight = 0
// export let startY = 100
// export let chessBoardWidth = 1
// export let chessBoardHeight = 1
export const canMoveAreaArr = []
export const canBuildAreaArr = []

//本地使用的数据,不进行网络发送的
export const localGameData={
    canMoveAreaArr:[],
    canBuildArea:[],
}

export const gameData = {
    //哪个玩家的回合
    turn: 0,
    //模式   1:选择棋子  2:选择移动目标
    // step: 1,
    //1:waiting  ; 2:playing ; 3:over
    status: commonConstant.GAME_STATUS_WAITING,
    winner: 0,
    row:19,
    col:11,
    chessWidth:0,
    chessHeight:0,
    startY:100,
    chessBoardWidth:0,
    chessBoardHeight:0,
    minaArea: [],
    mountainArea: [],
    wallArea: [],
    waterArea: [],
    animationInfo: animationInfo,
    player1: {
        id: 0,
        name: '',
        //'兵','红车','红马','红炮','相','仕','帅'
        canBuildChessArr: [
            {
                name: '仕',
                cost: 300,
                show: true,
                //冷却
                cooling: 0,
                coolTotal: 2,
            },
            {
                name: '相',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 3,
            },
            {
                name: '兵',
                cost: 100,
                show: false,
                cooling: 0,
                coolTotal: 2,
            },
            {
                name: '红车',
                cost: 400,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },
            {
                name: '红马',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },
            {
                name: '红炮',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },


            // {
            //     name: '帅',
            //     cost: '300',
            // }
        ],
        chessArr: [
            // {
            //     name: '帅',
            //     i: 6,
            //     j: 19,
            //     isElite: false,
            //     exp: 0,
            //     moved: false,
            // },
            // {
            //     name: '红车',
            //     i: 8,
            //     j: 18,
            //     isElite:true,
            //     exp:1000,
            // },

        ],
        unexploredArea: [],
        visibleArea: [],
        money: {
            total: 1000,
            increase: 0,
        }
    },
    player2: {
        id: 0,
        name: '',
        //'卒','黑车','黑马','黑炮','象','士','将'
        canBuildChessArr: [
            {
                name: '士',
                cost: 300,
                show: true,
                cooling: 0,
                coolTotal: 2,
            },
            {
                name: '象',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 3,
            },
            {
                name: '卒',
                cost: 100,
                show: false,
                cooling: 0,
                coolTotal: 2,
            },
            {
                name: '黑车',
                cost: 400,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },
            {
                name: '黑马',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },
            {
                name: '黑炮',
                cost: 300,
                show: false,
                cooling: 0,
                coolTotal: 5,
            },


            // {
            //     name: '将',
            //     cost: '300',
            // }
        ],
        chessArr: [
            // {
            //     name: '将',
            //     i: 6,
            //     j: 1,
            //     isElite: false,
            //     exp: 0,
            //     moved: false,
            // },


        ],
        unexploredArea: [],
        visibleArea: [],
        money: {
            total: 1000,
            increase: 0,
        }
    },
}

export const computeSize = (totalWidth) => {
    gameData.chessWidth = Math.round(totalWidth/gameData.col)
    gameData.chessBoardWidth = Math.round(totalWidth-gameData.chessWidth)
    gameData.chessHeight = gameData.chessWidth
    gameData.chessBoardHeight = Math.round(gameData.chessWidth*gameData.row-gameData.chessHeight)
}

export const importMapData = (map) => {
    gameData.col=map.col
    gameData.row=map.row
    gameData.minaArea=map.minaArea
    gameData.mountainArea=map.mountainArea
    gameData.wallArea=map.wallArea
    gameData.waterArea=map.waterArea
    gameData.player1.chessArr=map.player1.chessArr
    gameData.player2.chessArr=map.player2.chessArr

}